<?php

namespace App\Http\Controllers\Api;

use App\Models\Member;
use App\Repositories\Api\DailyMenuRepository;
use App\Repositories\Api\MemberRepository;
use App\Repositories\Api\ProductRepository;

class DailyMenuController extends MiniAppController
{
    private $memberRep = NULL,
        $menuRep = NULL,
        $productRep = NULL;

    public function __construct(
        MemberRepository    $memberRep,
        DailyMenuRepository $menuRep,
        ProductRepository   $productRep
    )
    {
        parent::__construct();

        $this->memberRep = $memberRep;
        $this->productRep = $productRep;
        $this->menuRep = $menuRep;
    }

    public function index()
    {
        $params = request()->all();
        $shop_id = intval(request()->get("shop_id"));
        empty($shop_id) && $shop_id = Member::query()->where('id', UID)->value("shop_supplier_id");

        /*if (empty($shop_id)) {
            return retFail("请选择餐厅二维码");
        }*/
        if (!$shop_id) {
            return retFail("店铺不存在");
        }

        $res = $this->menuRep->getMenusList($shop_id);

        return retSuc($res);
    }

}
